<template>
  <div id="app">
    <admin-hender></admin-hender>
    <el-container>
      <el-aside width="200px">
        <el-menu :default-openeds="['1']">
          <el-submenu :index="index + 1 + ''" v-for="(item, index) in navs">
            <template slot="title"><i class="el-icon-menu"></i>{{item.label}}</template>
            <el-menu-item :index="index + 1 + '-' + (index2 + 1)" 
              v-for="(item2, index2) in item.children"
              @click="routerHandler(item2)">
              {{item2.label}} 
            </el-menu-item>
            </el-submenu>
          </el-submenu>
        </el-menu>
      </el-aside>
      <router-view/>
    </el-container>
  </div>
</template>

<style>
  html {
    height: 100%;
  }
  body {
    min-height: 100%;
    padding-bottom: 36px;
    margin: 0;
  }
  .el-row {
    width: 100%;
  }

</style>

<script>
import Header from './components/common/header';
import navs from './assets/data/nav.conf';
export default {
  name: 'app',
  data () {
    return {
      navs,
      defaultProps: {
        children: 'children',
        label: 'label'
      }
    }
  },
   methods: {
    routerHandler(data) {
      if(data.router) {
        this.$router.push(data.router)
      }
    },
  },
  components: {
    'admin-hender': Header
  }
}
</script>

<style>

</style>
